package com.tj.jinzao.presenter;


import com.tj.jinzao.api.SubscriberCallBack;
import com.tj.jinzao.base.BasePresenter;
import com.tj.jinzao.base.IBaseView;
import com.tj.jinzao.manager.UserManager;
import com.tj.jinzao.model.ExchangeRecord;
import com.tj.jinzao.model.ResultResponse;
import java.util.List;

/**
 * 地址处理
 * Created by wjy 2018/12/10.
 */
public class ExchangeRecordPresenter extends BasePresenter<IBaseView<List<ExchangeRecord>>> {

    public ExchangeRecordPresenter(IBaseView<List<ExchangeRecord>> view) {
        super(view);
    }

    public void getExchangeRecord() {
        long uId = UserManager.getInstance().getUser().getId();
        addSubscription(mApiService.getExchangeList(uId)
                , new SubscriberCallBack<List<ExchangeRecord>>(mView.getContext()) {
                    @Override
                    protected void onSuccess(List<ExchangeRecord> list) {
                        if (mView != null) mView.onRequestSuccess(list);
                    }

                    @Override
                    protected void onFailure(ResultResponse response) {
                        if (mView != null) mView.onRequestError(response.getMessage());
                    }

                });
    }
}